#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time : 2021-12-1 17:41
# @Author : huabao.tan
# @File : creat_power_file.py
# @Software: PyCharm

from openpyxl import load_workbook
from power.allFunction import *
import xlwt


class CreatPower:

    def __init__(self):
        self.filename = open_file()
        self.open_excel()

    def object(self):
        self.name = c_name()
        self.other_name = c_name()
        self.card = creat_Idcard()
        self.edu = education()
        self.school_of_graduation = college()
        self.ranking = rank()
        self.dutying = duty()
        self.posting = post()
        self.politics_statused = politics_status()
        self.fosters = foster()
        self.sex = create_sex()
        self.birth_day = birthday(self.card)
        self.stat_word_time = randomtimes('1990-10-05', '1999-10-05', 1)[0]
        self.join_party_time = randomtimes('1995-10-05', '1999-10-05', 1)[0]
        self.second_stat_time = randomtimes('1995-10-05', '1999-10-05', 1)[0]
        self.graduate_time = randomtimes('1995-10-05', '2010-10-05', 1)[0]
        self.stat_birth = randomtimes('1970-10-05', '1990-10-05', 1)[0]
        self.positions = position()
        self.nations = nation()
        self.native_places = native_place()
        self.of_types = of_type()
        self.affiliation_types = affiliation_type()
        self.units = unit()
        self.specialtys = specialty()
        self.degrees = degree()
        self.learning_formats = learning_format()
        self.relations = relation()
        self.others_type = other_type()
        self.naures = nature()
        self.exchanges = exchange()

    def open_excel(self):
        self.workbook = load_workbook(self.filename)

    def get_sheet_by_index(self, index):
        self.sheetnames = self.workbook.sheetnames
        self.sheet = self.workbook[self.sheetnames[index]]
        return self.sheet

    def sheet_row_col_vlaue(self, index, row, col, value):
        self.sheetnames = self.workbook.sheetnames
        self.sheet = self.workbook[self.sheetnames[index]]
        self.sheet_index = copy(self.sheet)
        self.sheet_index.write(row=row, col=col, value=value)


if __name__ == '__main__':
    wrint = CreatPower()
    print(wrint.sheet_row_col_vlaue(0, 2, 2, c_name()))
